
import time
import functools

from src.utils.log_util import logger


def spend_time(descirbe):
    def print_spend_time(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            start_time = time.time()
            result = func(*args, **kwargs)
            spend_time = str(round((time.time() - start_time) * 1000, 2))
            logger.info(descirbe + " speed time: {}ms".format(str(spend_time)))
            return result
        return wrapper
    return print_spend_time
    

# 时间差
def time_difference(start_time):
    spend_time = str(round((time.time() - start_time) * 1000, 2))
    return spend_time